#include "YGConnectionManager.h"

#include "YGConnection.h"
#include "Error.h"
//#include "Engine.h"

namespace YoghurtGum
{

	Connection* g_Connection[32];
	unsigned int g_ConnectionTotal = 0;

	bool ConnectionManager::Init()
	{
		WSADATA data;
		if (WSAStartup(MAKEWORD(2, 2), &data) != NO_ERROR)
		{
			//ERROR_EXPLAIN("Couldn't initialize WSA.");
			return false;
		}

		return true;
	}

	Connection* ConnectionManager::Create(const char* a_Address, unsigned int a_Port)
	{
		g_Connection[g_ConnectionTotal] = new Connection();
		if (!g_Connection[g_ConnectionTotal]->Connect(a_Address, a_Port))
		{
			g_Connection[g_ConnectionTotal] = NULL;
			return NULL;
		}

		return g_Connection[g_ConnectionTotal++];
	}

}; // namespace YoghurtGum
